global indata "/.../data"
global output "/.../output"
set more off
set linesize 255

*-------------------------------------------------------------------------------
* Author: Dhiren Patki
*
* This program computes match rates for the sample of single-employer DB plans 
* that can be matched to the BR between 1997 and 2014.
* The input file used for these statistics is f55brmtch_cratio.csv which is 
* produced in 02_5500BRB.sas
*-------------------------------------------------------------------------------

import delimited $indata/f55brmtch_cratio.csv, stringcol(1,2) clear

*Prepare output table
matrix f55brm=J(1,3,.)
sum match_br
matrix f55brm[1,1]=r(N)
matrix f55brm[1,2]=r(mean)
sum match_br [aw=adj_db_partcp]
matrix f55brm[1,3]=r(mean)

*Output table
clear
svmat f55brm
rename f55brm1 plnyrcnt
rename f55brm2 mtchrt
rename f55brm3 mtchrt_ptcpwt
label var plnyrcnt "Plan-years"
label var mtchrt "Match rate"
label var mtchrt_ptcpwt "Participant wtd match rate"
export delimited $output/f55brmatch.csv, datafmt replace

